import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const userIdKey = 'agencyUser-Id'
const provinceKey = 'province'
const cityKey = 'city'
const areaKey = 'area'
const areaArrKey = 'areaArr'
const imgKey = 'imgUrl'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

//userid
export function getUserId() {
  return Cookies.get(userIdKey)
}

export function setUserId(userId) {
  return Cookies.set(userIdKey, userId)
}

export function removeUserId() {
  return Cookies.remove(userIdKey)
}

//province
export function getProvince() {
  return Cookies.get(provinceKey)
}

export function setProvince(province) {
  return Cookies.set(provinceKey, province)
}

export function removeProvince() {
  return Cookies.remove(provinceKey)
}

//city
export function getCity() {
  return Cookies.get(cityKey)
}

export function setCity(city) {
  return Cookies.set(cityKey, city)
}

export function removeCity() {
  return Cookies.remove(cityKey)
}

//areaArr
export function getAreaArr() {
	let agencyAreaArr = localStorage.getItem(areaArrKey)
	if(agencyAreaArr){
		agencyAreaArr = JSON.parse(agencyAreaArr)
	}
  return agencyAreaArr
}

export function setAreaArr(areaArr) {
	console.log('cookie::areaArr' + JSON.stringify(areaArr))
  return localStorage.setItem(areaArrKey, JSON.stringify(areaArr))
}

export function removeAreaArr() {
  return localStorage.removeItem(areaArrKey)
}

//area
export function getArea() {
  return Cookies.get(areaKey)
}

export function setArea(area) {
  return Cookies.set(areaKey, area)
}

export function removeArea() {
  return Cookies.remove(areaKey)
}

//imgUrl
export function getImgUrl() {
  return Cookies.get(imgKey)
}

export function setImgUrl(imgUrl) {
  return Cookies.set(imgKey, imgUrl)
}

export function removeImgUrl() {
  return Cookies.remove(imgKey)
}